class Manage::PeopleController < Manage::BaseController
  inherit_resources

  load_and_authorize_resource :class => Person
  
  has_scope :with_name, :as => :name, :only => :index
  has_scope :with_ip, :as => :ip, :only => :index
  order_by :created_at
  
  def create
    create!{ manage_people_path }
  end
  
  def update
    update!{ manage_people_path }
  end
  
  def destroy
    destroy!{ manage_people_path }
  end
  
  protected
    
    def collection
      @answers = Answer.all.group_by(&:person_id)
      @people = (@people || end_of_association_chain).order(search_filter.order).includes(:answers).page(params[:page])
    end
end
